Conversation
- Separate Sentry init from plugin (user inits Sentry, plugin handles navigation spans) - Move @sentry/browser, @sentry/core, @stackflow/core to peerDependencies - Replace internal WINDOW import with direct window check - Remove unsafe integrations type cast - Extract shared navigation span helper and add breadcrumb support - Upgrade devDependencies to @sentry/browser@10, @sentry/core@10 - Fix version field typo (commas to dots) - Update README with two-step setup guide Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 3a116b3 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ❌ Deployment failed View logs |
stackflow-docs | 3a116b3 | Mar 30 2026, 10:08 AM |
commit: |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (2)
📝 WalkthroughSummary by CodeRabbit
WalkthroughAdds a new Stackflow Sentry extension under Changes
Sequence Diagram(s)sequenceDiagram
participant Activity as Stackflow Activity
participant Plugin as Sentry Plugin
participant Sentry as Sentry SDK
participant Browser as Browser
Activity->>Plugin: emit onPushed/onPopped/onReplaced (action, activity, params)
Plugin->>Sentry: Sentry.getClient() (guard)
alt client available
Plugin->>Sentry: start navigation span ("<action> <activity>") with attrs (op, origin, source, stackflow.*)
Plugin->>Sentry: addBreadcrumb(category:"navigation", message:"<action> <activity>", data: params)
else no client
Plugin-->>Activity: skip span/breadcrumb
end
Browser->>Sentry: stackflowBrowserTracingIntegration.afterAllSetup()
alt instrumentPageLoad enabled & browser
Sentry->>Sentry: start page-load span (name=window.location.pathname, attrs: op=pageload, origin=auto.pageload.stackflow)
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (2)
extensions/plugin-sentry/esbuild.config.js (1)
29-29: Log the build error before exiting for faster failure diagnosis.At Line 29, the catch block drops error details, which makes CI/local troubleshooting harder.
🔧 Suggested improvement
-]).catch(() => process.exit(1)); +]).catch((error) => { + console.error(error); + process.exit(1); +});🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@extensions/plugin-sentry/esbuild.config.js` at line 29, The current promise rejection handler .catch(() => process.exit(1)) discards the error; update the catch to accept the error (e.g., .catch((err) => { /* log */ })) and log the error before exiting (for example call console.error or the project's logger with a clear message like "Build failed" plus err) and then call process.exit(1) so failures are visible in CI/local runs.extensions/plugin-sentry/src/integration.ts (1)
33-33: Prefer normalized pageload names over raw pathname.Using
window.location.pathnamedirectly can create high-cardinality transaction names (and may carry IDs). A normalized route-style name is safer for aggregation.♻️ Proposed refinement
+function normalizeTransactionPath(pathname: string): string { + return pathname + .replace(/\/\d+(?=\/|$)/g, "/:id") + .replace( + /\/[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}(?=\/|$)/gi, + "/:id", + ); +} + export function stackflowBrowserTracingIntegration( options: Parameters<typeof originalBrowserTracingIntegration>[0] = {}, ) { @@ if (instrumentPageLoad && initialWindowLocation) { startBrowserTracingPageLoadSpan(client, { - name: initialWindowLocation.pathname, + name: normalizeTransactionPath(initialWindowLocation.pathname), attributes: { [SEMANTIC_ATTRIBUTE_SENTRY_OP]: "pageload", [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: "auto.pageload.stackflow", [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: "url", }, }); }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@extensions/plugin-sentry/src/integration.ts` at line 33, The code uses initialWindowLocation.pathname for transaction/route naming which can produce high-cardinality and leak IDs; update the usage in integration.ts to normalize the page load name (e.g., map or sanitize initialWindowLocation.pathname via a normalizeRoute or sanitizePath function) before assigning to the transaction name, replacing direct references to initialWindowLocation.pathname; ensure the normalizer strips or tokenizes dynamic segments (IDs, UUIDs, numeric params) and returns a stable route-style string for Sentry aggregation.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@extensions/plugin-sentry/package.json`:
- Line 30: The dev script in package.json uses "yarn build:js --watch && yarn
build:dts --watch" so the second watcher never starts; change the dev script to
run both watchers concurrently (e.g., use the "concurrently" tool to run "yarn
build:js --watch" and "yarn build:dts --watch" in parallel) and add
"concurrently" to devDependencies if it's not already installed so both watchers
(build:js and build:dts) run at the same time.
- Around line 33-34: The code currently depends on the unstable internal hook
browserTracingIntegration().afterAllSetup (used in integration.ts) while
package.json allows ">=8.0.0" for `@sentry/browser` and `@sentry/core`; either
refactor to remove the internal hook by wiring Sentry using the public APIs
(replace browserTracingIntegration().afterAllSetup usage with calls to
startBrowserTracingNavigationSpan and startBrowserTracingPageLoadSpan in the
appropriate initialization flow) or lock the peerDependency range to a tested
major (e.g., change ">=8.0.0" to "^8.0.0" or "^8") to prevent unexpected
breaking changes. Ensure you update integration.ts to reference only
startBrowserTracingNavigationSpan and startBrowserTracingPageLoadSpan if you
choose the refactor, or update package.json ranges consistently if you choose
pinning.
---
Nitpick comments:
In `@extensions/plugin-sentry/esbuild.config.js`:
- Line 29: The current promise rejection handler .catch(() => process.exit(1))
discards the error; update the catch to accept the error (e.g., .catch((err) =>
{ /* log */ })) and log the error before exiting (for example call console.error
or the project's logger with a clear message like "Build failed" plus err) and
then call process.exit(1) so failures are visible in CI/local runs.
In `@extensions/plugin-sentry/src/integration.ts`:
- Line 33: The code uses initialWindowLocation.pathname for transaction/route
naming which can produce high-cardinality and leak IDs; update the usage in
integration.ts to normalize the page load name (e.g., map or sanitize
initialWindowLocation.pathname via a normalizeRoute or sanitizePath function)
before assigning to the transaction name, replacing direct references to
initialWindowLocation.pathname; ensure the normalizer strips or tokenizes
dynamic segments (IDs, UUIDs, numeric params) and returns a stable route-style
string for Sentry aggregation.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 3792b7af-fc17-4567-85e4-7f8821d1d63d
⛔ Files ignored due to path filters (7)
.yarn/cache/@sentry-browser-npm-10.46.0-91e2f4dcc5-f447c01f96.zipis excluded by!**/.yarn/**,!**/*.zip.yarn/cache/@sentry-core-npm-10.46.0-8ff3972576-bbe823f9de.zipis excluded by!**/.yarn/**,!**/*.zip.yarn/cache/@sentry-internal-browser-utils-npm-10.46.0-c2bfafc8a9-6ae7c6cc8d.zipis excluded by!**/.yarn/**,!**/*.zip.yarn/cache/@sentry-internal-feedback-npm-10.46.0-94a0d30ebb-e6c0b1fa93.zipis excluded by!**/.yarn/**,!**/*.zip.yarn/cache/@sentry-internal-replay-canvas-npm-10.46.0-e0dee1cb26-0ddfacfc79.zipis excluded by!**/.yarn/**,!**/*.zip.yarn/cache/@sentry-internal-replay-npm-10.46.0-21ab33d9b1-e7c3e9e880.zipis excluded by!**/.yarn/**,!**/*.zipyarn.lockis excluded by!**/yarn.lock,!**/*.lock
📒 Files selected for processing (9)
.changeset/fix-plugin-sentry.md.pnp.cjsextensions/plugin-sentry/README.mdextensions/plugin-sentry/esbuild.config.jsextensions/plugin-sentry/package.jsonextensions/plugin-sentry/src/index.tsextensions/plugin-sentry/src/integration.tsextensions/plugin-sentry/src/sentryPlugin.tsextensions/plugin-sentry/tsconfig.json
| "build:dts": "tsc --emitDeclarationOnly", | ||
| "build:js": "node ./esbuild.config.js", | ||
| "clean": "rimraf dist", | ||
| "dev": "yarn build:js --watch && yarn build:dts --watch" |
There was a problem hiding this comment.
dev script won’t run both watchers.
yarn build:js --watch is long-running, so yarn build:dts --watch never starts with &&.
🔧 Proposed fix
- "dev": "yarn build:js --watch && yarn build:dts --watch"
+ "dev": "concurrently \"yarn build:js --watch\" \"yarn build:dts --watch\"" "devDependencies": {
+ "concurrently": "^9.0.0",
"@sentry/browser": "^10.46.0",
"@sentry/core": "^10.46.0",🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@extensions/plugin-sentry/package.json` at line 30, The dev script in
package.json uses "yarn build:js --watch && yarn build:dts --watch" so the
second watcher never starts; change the dev script to run both watchers
concurrently (e.g., use the "concurrently" tool to run "yarn build:js --watch"
and "yarn build:dts --watch" in parallel) and add "concurrently" to
devDependencies if it's not already installed so both watchers (build:js and
build:dts) run at the same time.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
🧹 Nitpick comments (1)
extensions/plugin-sentry/src/sentryPlugin.ts (1)
64-103: Correct implementation matching Stackflow's Effect types.The hook implementations correctly match the Effect type definitions:
- Activity-level hooks access
effect.activityonStepPushed/onStepReplacedcorrectly mergeeffect.step.paramsonStepPoppedcorrectly does not accessstep(per Effect.ts,STEP_POPPEDhas nostepfield)The repeated call pattern could optionally be consolidated into a single helper, but the current explicit form is clear.
♻️ Optional: Extract common tracing helper
+function traceNavigation( + action: NavigationAction, + activityName: string, + params: Record<string, string | undefined>, +): void { + startNavigationSpan(action, activityName, params); + addNavigationBreadcrumb(action, activityName, params); +} + export function sentryPlugin(): StackflowPlugin { return () => ({ key: "plugin-sentry", onPushed({ effect }) { const { name, params } = effect.activity; - startNavigationSpan("push", name, params); - addNavigationBreadcrumb("push", name, params); + traceNavigation("push", name, params); }, // ... apply similarly to other hooks }); }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@extensions/plugin-sentry/src/sentryPlugin.ts` around lines 64 - 103, The implementations in sentryPlugin correctly follow Stackflow Effect types but you can reduce repetition by extracting a small helper inside sentryPlugin that takes (action: string, effect: Effect) or (action: string, name: string, params: Record) and calls startNavigationSpan and addNavigationBreadcrumb; then replace the bodies of onPushed, onPopped, onReplaced, onStepPushed, onStepPopped, and onStepReplaced to invoke that helper (ensure step params are merged in onStepPushed/onStepReplaced and not accessed in onStepPopped).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@extensions/plugin-sentry/src/sentryPlugin.ts`:
- Around line 64-103: The implementations in sentryPlugin correctly follow
Stackflow Effect types but you can reduce repetition by extracting a small
helper inside sentryPlugin that takes (action: string, effect: Effect) or
(action: string, name: string, params: Record) and calls startNavigationSpan and
addNavigationBreadcrumb; then replace the bodies of onPushed, onPopped,
onReplaced, onStepPushed, onStepPopped, and onStepReplaced to invoke that helper
(ensure step params are merged in onStepPushed/onStepReplaced and not accessed
in onStepPopped).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 1bcad8f2-cc64-4004-aacc-5a45b3bc0fde
📒 Files selected for processing (1)
extensions/plugin-sentry/src/sentryPlugin.ts
…set to minor Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
plugin-sentry (Issue from #520)
Stackflow has a unique screen handling with "Activity."
Currently, Sentry doesn't support tracing for this mechanism,
so we created a dedicated plugin.
This PR contains a plugin that provides:
Changes from #547
Sentry.init()themselves and addstackflowBrowserTracingIntegration()to their integrations@sentry/browser,@sentry/core,@stackflow/coreto peerDependencies@sentry/types(deprecated in v8) andWINDOWinternal API usageonStepPushed,onStepPopped,onStepReplaced)0,0,0→0.0.0)How to use